home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / sqlitemanager / include / SQLiteSelect.class.php < prev    next >
Encoding:
PHP Script  |  2006-04-18  |  5.1 KB  |  150 lines

  1. <?php
  2. /**
  3. * Web based SQLite management
  4. * Class for generate 'Select' querys
  5. * @package SQLiteManager
  6. * @author MaurΆcio M. Maia <mauricio.maia@gmail.com>
  7. * @version $Id: SQLiteSelect.class.php,v 1.18 2006/04/14 15:16:52 freddy78 Exp $ $Revision: 1.18 $
  8. */
  9.  
  10. class SQLiteSelect {
  11.  
  12.     /**
  13.     * reference to the connection object
  14.     *
  15.     * @access public
  16.     * @var object
  17.     */
  18.     var $connId;
  19.  
  20.     /**
  21.     * TABLE name
  22.     *
  23.     * @access private
  24.     * @var string
  25.     */
  26.     var $table;
  27.  
  28.  
  29.     /**
  30.     * Class constructor
  31.     *
  32.     * @access public
  33.     * @param string $conn reference to the connection object
  34.     */
  35.     function SQLiteSelect(&$conn){
  36.         // constructeur de la classe
  37.         $this->connId = $conn;
  38.         if($GLOBALS['table']) {
  39.             $this->table = $GLOBALS['table'];
  40.         } elseif($GLOBALS['TableName']){
  41.             $this->table = $GLOBALS['TableName'];
  42.         } else if($GLOBALS['view']) {
  43.             $this->table = $GLOBALS['view'];
  44.         } elseif($GLOBALS['ViewName']){
  45.             $this->table = $GLOBALS['ViewName'];
  46.         } else return false;
  47.         switch(isset($GLOBALS['select_action'])? $GLOBALS['select_action'] : '' ){
  48.             case '':
  49.                 $this->getTableInfo($this->table);
  50.                 $this->form();
  51.                 break;
  52.         }
  53.     }
  54.  
  55.     /**
  56.     * Get some table properties
  57.     *
  58.     * @access public
  59.     * @param string $table table name
  60.     */
  61.     function getTableInfo($table=''){
  62.         if(empty($table)) $table = $this->table;
  63.         $this->connId->getResId('PRAGMA table_info('.brackets($table).');');
  64.         $this->infoTable = $this->connId->getArray();
  65.         return $this->infoTable;
  66.     }
  67.  
  68.     /**
  69.     * Display Form for select table records
  70.     *
  71.     * @access public
  72.     * @param string $req query where the record is
  73.     * @param integer $numId Number of the query record
  74.     * @param boolean $error if true, display POST value
  75.     */
  76.     function form(){
  77.       echo '<!-- SQLiteSelect.class.php : form() -->'."\n";
  78.         echo '<center><h4>'.$GLOBALS["traduct"]->get(201).'</h4>'."\n";
  79.         echo '<form name="select" action="main.php?dbsel='.$GLOBALS['dbsel'].'&table='.$this->table.'" method="POST" target="main">'."\n";
  80.         echo '    <table class="Insert" cellpadding="2" cellspacing="0" width="80%">
  81.                     <thead>
  82.                     <tr>
  83.                         <td align="center" class="Browse">'.$GLOBALS["traduct"]->get(73).'</td>
  84.                         <td align="center" class="Browse">'.$GLOBALS['traduct']->get(27).'</td>
  85.                         <td align="center" class="Browse">'.$GLOBALS['traduct']->get(28).'</td>
  86.                         <td align="center" class="Browse">'.$GLOBALS['traduct']->get(202).'</td>
  87.                         <td align="center" class="Browse">'.$GLOBALS['traduct']->get(50).'</td>
  88.                     </tr>
  89.                     </thead>';
  90.         reset($this->infoTable);
  91.       if (!isset($tabData)) $tabData = array();
  92.         while(list($cid, $tabInfo) = each($this->infoTable)){
  93.             $this->lineElement($tabInfo, $tabData);
  94.         }
  95.         echo '    <tr>
  96.                     <td style="text-align:left" colspan="10">     '.displayPics('arrow_ltr.gif').' 
  97.                     <a href="#" onClick="javascript:setCheckBox(\'select\',\'showField\',true);" class="Browse">'.$GLOBALS['traduct']->get(34).'</a> / 
  98.                     <a href="#" onClick="javascript:setCheckBox(\'select\', \'showField\', false);" class="Browse">'.$GLOBALS['traduct']->get(35).'</a>';
  99.         echo '    <tr>
  100.                     <td colspan="4"> </td><td class="TitleHeader" style="text-align:left">'.$GLOBALS["traduct"]->get(203).'</td>
  101.                 </tr>'."\n";
  102.         echo '    <tr>
  103.                     <td colspan="3"> </td>'."\n".'
  104.                     <td style="text-align:right; white-space: nowrap">
  105.                         <label for="AND">'.$GLOBALS["traduct"]->get(204).'</label><input type="radio" name="operSuppl" id="AND" value="AND" checked="checked"><br/>
  106.                         <label for="OR">'.$GLOBALS["traduct"]->get(205).'</label><input type="radio" name="operSuppl" id="OR" value="OR">
  107.                     </td>
  108.                     <td style="text-align:left">
  109.                         <textarea name="CondSuppl" cols="'.TEXTAREA_NB_COLS.'" rows="4"></textarea>
  110.                     </td>
  111.                 </tr>';
  112.         echo '</table>';
  113.         if(isset($req)) {
  114.             echo '<input type="hidden" name="numId" value="'.$numId.'">'."\n";
  115.             echo '<input type="hidden" name="req" value="'.urlencode($req).'">'."\n";
  116.         }
  117.         echo '<input type="hidden" name="action" value="selectElement">'."\n";
  118.         if(isset($_REQUEST['currentPage'])) echo '<input type="hidden" name="currentPage" value="'.$_REQUEST['currentPage'].'">'."\n";
  119.  
  120.         echo '<input class="button" type="submit" value="'.$GLOBALS["traduct"]->get(201).'" onclick="document.tabprop.submit();">';
  121.         echo '</form>';
  122.         echo '</center>';
  123.         return;
  124.     }
  125.  
  126.     /**
  127.     * Display on column for select records
  128.     *
  129.     * @access private
  130.     * @param array $infoTable table properties
  131.     * @param array $tabValue current value for modify record
  132.     */
  133.     function lineElement($infoTable, $tabValue=''){
  134.         if(!isset($tabValue[$infoTable['name']])) $tabValue[$infoTable['name']] = '';
  135.         echo '    <tr>
  136.                     <td align="center" class="Insert"><input type="checkbox" name="showField['.$infoTable['name'].']"'.(($tabValue[$infoTable['name']]=='')? ' checked="checked"' : '' ).'></td>
  137.                     <td align="left" class="Insert">'.$infoTable['name'].'</td>
  138.                     <td align="center" class="Insert">'.StrToUpper($infoTable['type']).'</td>
  139.                     <td align="center" class="Insert">'.SQLiteSelectList($infoTable['name']).'</td>
  140.                     <td align="left" class="Insert">'.SQLiteInputType($infoTable, $tabValue[$infoTable['name']], false, false).'</td>
  141.                 </tr>';
  142.         return;
  143.     }
  144.  
  145. }
  146.  
  147. ?>
  148.  
  149.  
  150.